<?php
namespace app\api\controller;

use library\Controller;
use think\Db;

class Test extends Controller{
	
    public function testttt()
    {
        $a = 'abc';
        $this->success('ok',$a);
    }
    
    
    public function replace_domain()
    {
        $new_ip = 'http://39.105.191.15:8077';
        $old_ip = 'http://kunying.cc';
        
        $list =  Db::name('system_product')->select();
       
        foreach($list as $k=>$v){
       		$new_content = str_replace($old_ip,$new_ip,$v['content']);
       		Db::name('system_product')->where(['id'=>$v['id']])->update(['content'=>$new_content]);
        }
        
        
        $orders =  Db::name('system_order')->field('id,content,material')->select();
       
        foreach($orders as $k=>$v){
       		$new_content = str_replace($old_ip,$new_ip,$v['content']);
       		$new_material = str_replace($old_ip,$new_ip,$v['material']);
       		Db::name('system_order')->where(['id'=>$v['id']])->update(['content'=>$new_content,'material'=>$new_material]);
        }
               
       $this->success('ok');
    }
}